defmodule WordCount do
  @doc """
  Count the number of words in the sentence.

  Words are compared case-insensitively.
  """
  #@div_words ["!", "&", "$", "%", "^", "@", ":", "_", ",", " "]
  @regexp ~r/[^[:alnum:]-]/u

  @spec count(String.t()) :: map
  def count(sentence) do
    sentence
    |> String.downcase()
    |> String.split(@regexp, trim: true)
    |> Enum.reduce(%{}, fn word, acc -> Map.update(acc, word, 1, &(&1 + 1)) end)

  end


end
